package com.seven;

import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ClassUtil;
import com.seven.listener.HelloSpringApplicationRunListener;
import org.springframework.util.Assert;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;

/**
 * @Author seven
 * @Date 2020/5/6 16:40
 **/

public class Commons {
/*    public static void main(String[] args) {
        System.out.println(Commons.getClassNameAndMethod(HelloSpringApplicationRunListener.class, "starting"));
    }*/
    private static final String lian="-->";
    public static String getClassNameAndMethod(Class<?> c,String methodName){

        return getLast(ClassUtil.getClassName(c,true))+lian+getLast(ClassUtil.getDeclaredMethod(c, methodName).toString());
    }
    public static String getLast(String s){
        Assert.notNull(s,"字符串不能为空");
        String[] split = s.split("\\.");
        if (ArrayUtil.isEmpty(split)){
            return s;
        }
        return split[split.length-1];
    }
}
